package ec.ups.edu.proyecto.modelo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotEmpty;

@Entity
public class Rol implements Serializable
{

   /**
	 * 
	 */
	private static final long serialVersionUID = 1L;


   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id_rol", updatable = false, nullable = false)
   private Long id = null;


   @NotNull
   @NotEmpty
   @Size(min = 4, max = 25)
	@Column(name="rol_codigo")
   private String codigo;

   @NotNull
   @NotEmpty
   @Size(min = 4, max = 25)
	@Column(name="rol_descripcion")
   private String descripcion;

   public Long getId()
   {
      return this.id;
   }

   public void setId(final Long id)
   {
      this.id = id;
   }



   @Override
   public boolean equals(Object that)
   {
      if (this == that)
      {
         return true;
      }
      if (that == null)
      {
         return false;
      }
      if (getClass() != that.getClass())
      {
         return false;
      }
      if (id != null)
      {
         return id.equals(((Rol) that).id);
      }
      return super.equals(that);
   }

   @Override
   public int hashCode()
   {
      if (id != null)
      {
         return id.hashCode();
      }
      return super.hashCode();
   }

   public String getCodigo()
   {
      return this.codigo;
   }

   public void setCodigo(final String codigo)
   {
      this.codigo = codigo;
   }

   public String getDescripcion()
   {
      return this.descripcion;
   }

   public void setDescripcion(final String descripcion)
   {
      this.descripcion = descripcion;
   }

   @Override
   public String toString()
   {
      String result = getClass().getSimpleName() + " ";
      if (codigo != null && !codigo.trim().isEmpty())
         result += "codigo: " + codigo;
      if (descripcion != null && !descripcion.trim().isEmpty())
         result += ", descripcion: " + descripcion;
      return result;
   }
}